Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google signing #112

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

richardbeare
Copy link

Hi,
These patches support use of a google clientID and digital signature generated from the private cryptographic key. The details of using the signature are hidden away at the bottom of:

https://developers.google.com/maps/documentation/geocoding/get-api-key#premium-auth

Python code is down the bottom too.

It turns out it isn't a matter of combining the key and client id in the url, which was what the existing code appears to do, but rather using the key to create a signature for the rest of the url and appending that. Originally I was using our organisational plan via modified versions of ggmap functions and calling python from R. However, the updated version of ggmap makes the integration much easier, and worth figuring out how to avoid the python part.

Apologies if there is yet another version of google authentication that the patches I've suggested breaks. I don't think this is the case. I've tested all the examples after setting the client id and signature using

register_google(account_type="premium", client=clientID, signature=privatekey)

and everything seems OK when using my organisational details. If it isn't too widely used, it may be appropriate to change the "signature" term to "secretkey". I haven't done that.

My implementation of the signing function adds a dependency on urltools, which you may not like. Let me know If you'd prefer some other url parser instead. The other dependency is base64enc.

Potential weaknesses - the python signer mentions url safe base 64 encoding. Some searching suggests that this is a matter of swapping characters around. I'm not completely convinced I've done this in the appropriate place. I've done it using character translation after encoding/decoding. However it may be better to change the encoding/decoding alphabet. I'm not sure yet whether this is possible with existing R base64 encoding functions.

@richardbeare
Copy link
Author

Second patch contains modifications to mapdist. It now makes a single query to the mapdist api. The current version does one query per origin/destination pair. There is also some support for including place ids.

@dkahle
Copy link
Owner

dkahle commented Nov 17, 2016

Thanks for the updates! Can you fix the new conflict with mapdist and re-push please?

@fresques
Copy link

+1 would like this fix!

@richardbeare
Copy link
Author

The first part has been sitting in the "GoogleSigningSquashed" branch for ages. I'd recommend some checking of the distmap function I've modified. It works differently to the original version, in that it returns a matrix direct from the api call, meaning it is many times faster because many results can be returned from a single API call. However it has quite a different structure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants